home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / STREAM13.ARJ / LOGDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-18  |  1KB  |  55 lines

  1. {$B-}   { Use fast boolean evaluation. }
  2.  
  3. program logdemo;
  4.  
  5. { Demonstrates use of TLogFilter }
  6.  
  7. uses
  8.   {$ifdef windows}
  9.   wobjects,wincrt,
  10.   {$else}
  11.   objects,
  12.   {$endif windows}
  13.   streams;
  14.  
  15. var
  16.   i : integer;
  17.   inlog,log : PLogFilter;
  18.  
  19. begin
  20.   { Log both input and output to Logdemo.out }
  21.  
  22.   new(log, init( new(PDOSStream, init('Logdemo.out',stCreate))));
  23.  
  24.   log^.log(input);
  25.   log^.log(output);
  26.  
  27.   writeln('This is the Logdemo program, which logs input and output');
  28.   writeln('to LOGDEMO.OUT');
  29.   write('Enter an integer:');
  30.   readln(i);
  31.   writeln('Logging will now be turned off.');
  32.  
  33.   if not log^.unlog(input) then;   { This is one way to stop logging. }
  34.   close(output);       { This is another way. }
  35.  
  36.   { Re-open output; input was never closed. }
  37.   rewrite(output);
  38.  
  39.   writeln('This line will not be logged.');
  40.   write('Enter another integer:');
  41.   readln(i);
  42.   writeln('Logging will be turned back on now.');
  43.  
  44.   log^.log(input);
  45.   log^.log(output);
  46.  
  47.   writeln('This line will be logged to the file.');
  48.  
  49.   writeln('All done now; close the log.');
  50.  
  51.   dispose(log,done);
  52.  
  53.   writeln('The log has been closed, so this line won''t be logged.');
  54. end.
  55.